package com.yc.bos.dao.impl;

import com.yc.bos.dao.IUserDao;
import com.yc.bos.dao.base.BaseDaoImpl;
import com.yc.bos.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class UserDaoImpl extends BaseDaoImpl<User> implements IUserDao {
    @Override
    public User findByEmail(String email) {
        return null;
    }



    @Override
    public User find(String username, String password) {
        String hql="from User where username=? and password=?";
        List<User> list=hibernateTemplate.find(hql,username,password);
        if(list.size()==1){
            return list.get(0);
        }
        return null;
    }

    @Override
    public User findByUsername(String username) {
        String hql="from User where username=? ";
        List<User> list=hibernateTemplate.find(hql,username );
        if(list.size()==1){
            return list.get(0);
        }
        return null;
    }
}
